/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PanelSeleccionDirectorios.java
 *
 * Created on 11-jun-2011, 19:23:19
 */

package generadordeclasesv003.Vista;

import generadordeclasesv003.Controlador.Controlador_GestorPrograma;
import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.JTextField;


/**
 *
 * @author Administrador
 */
public class PanelSeleccionDirectorios extends javax.swing.JFrame {
private File fileDirExistentes;
    //**********************VARIABLES GLOBALES**************************************


    //**********************FIN - VARIABLES GLOBALES**************************************
    private static PanelSeleccionDirectorios panel;
JFileChooser fch=null;
    /** Creates new form PanelSeleccionDirectorios */
    public PanelSeleccionDirectorios() {
        initComponents();

    }

    //************************METODOS************************************

    public static PanelSeleccionDirectorios GetInstancia(){

        if(panel==null){
            panel=new PanelSeleccionDirectorios();
        }
            return panel;
    }
    public static void Mostrar_PanelSeleccionDirectorios(){
     GetInstancia().setVisible(true);
    }
    public static void Ocultar_PanelSeleccionDirectorios(){
        panel.setVisible(false);
    }
    public void MostrarJFileChooser_ClasesExistentes(JTextField txt,File fi){
    
    
    }




    //************************FIN - METODOS************************************
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        txt_DirExistentesClases = new javax.swing.JTextField();
        txt_DirCreacionClases = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        txt_DirCreacionMappings = new javax.swing.JTextField();
        botton_ClasesExistentes = new javax.swing.JButton();
        botton_CreacionClases = new javax.swing.JButton();
        botton_CreacionMappings = new javax.swing.JButton();
        Boton_OK = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Seleccion de Directorios");
        setResizable(false);

        jLabel1.setText("Direccion de  Clases Existentes:");

        txt_DirExistentesClases.setEditable(false);

        txt_DirCreacionClases.setEditable(false);

        jLabel3.setText("Paquete de Creacion de Clases:");

        jLabel2.setText("Paquete de Creacion de Mappings:");

        txt_DirCreacionMappings.setEditable(false);

        botton_ClasesExistentes.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/027-folder_search.gif"))); // NOI18N
        botton_ClasesExistentes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botton_ClasesExistentesActionPerformed(evt);
            }
        });

        botton_CreacionClases.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/027-folder_search.gif"))); // NOI18N
        botton_CreacionClases.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botton_CreacionClasesActionPerformed(evt);
            }
        });

        botton_CreacionMappings.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/027-folder_search.gif"))); // NOI18N
        botton_CreacionMappings.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botton_CreacionMappingsActionPerformed(evt);
            }
        });

        Boton_OK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/accept_16x16-32.gif"))); // NOI18N
        Boton_OK.setText("Aceptar");
        Boton_OK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Boton_OKActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel1)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txt_DirExistentesClases, javax.swing.GroupLayout.PREFERRED_SIZE, 452, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txt_DirCreacionClases, javax.swing.GroupLayout.PREFERRED_SIZE, 452, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txt_DirCreacionMappings, javax.swing.GroupLayout.PREFERRED_SIZE, 452, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(botton_CreacionMappings, 0, 0, Short.MAX_VALUE)
                    .addComponent(botton_CreacionClases, 0, 0, Short.MAX_VALUE)
                    .addComponent(botton_ClasesExistentes, javax.swing.GroupLayout.PREFERRED_SIZE, 37, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(585, Short.MAX_VALUE)
                .addComponent(Boton_OK)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(txt_DirExistentesClases))
                    .addComponent(botton_ClasesExistentes))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(botton_CreacionClases, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(txt_DirCreacionClases, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel3)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(botton_CreacionMappings, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(txt_DirCreacionMappings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addComponent(Boton_OK)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void botton_ClasesExistentesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botton_ClasesExistentesActionPerformed
     fch=new JFileChooser();
    fch.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    int res=fch.showOpenDialog(null);
    if(res==JFileChooser.APPROVE_OPTION){
     txt_DirExistentesClases.setText(fch.getSelectedFile().getAbsolutePath());
     Controlador_GestorPrograma.GetInstancia().CargarClasesExistentes(fch.getSelectedFile());
      }
    fch=null;

    }//GEN-LAST:event_botton_ClasesExistentesActionPerformed

    private void botton_CreacionClasesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botton_CreacionClasesActionPerformed
      // this.MostrarJFileChooser_ClasesExistentes(txt_DirCreacionClases);
    }//GEN-LAST:event_botton_CreacionClasesActionPerformed

    private void botton_CreacionMappingsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botton_CreacionMappingsActionPerformed
    //this.MostrarJFileChooser_ClasesExistentes(txt_DirCreacionMappings);        // TODO add your handling code here:
    }//GEN-LAST:event_botton_CreacionMappingsActionPerformed

    private void Boton_OKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Boton_OKActionPerformed

        if(!txt_DirExistentesClases.getText().trim().isEmpty()){
        panelIndex.getInstancia().cargame();
        }
        
        Ocultar_PanelSeleccionDirectorios();

      
       
    }//GEN-LAST:event_Boton_OKActionPerformed

    /**
    * @param args the command line arguments
    */



    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Boton_OK;
    private javax.swing.JButton botton_ClasesExistentes;
    private javax.swing.JButton botton_CreacionClases;
    private javax.swing.JButton botton_CreacionMappings;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JTextField txt_DirCreacionClases;
    private javax.swing.JTextField txt_DirCreacionMappings;
    private javax.swing.JTextField txt_DirExistentesClases;
    // End of variables declaration//GEN-END:variables

}
